package com.basker.pisces.service.dto;

import com.alibaba.fastjson.annotation.JSONField;

public interface IServiceResult<TData> {
    static final int SUCCESS_STATUS = 1;
    static final int FAILURE_STATUS = -1;

    static final String SUCCESS_MESSAGE = "success";
    static final String FAILURE_MESSAGE = "failure";

    /**
     * 如果执行成功，该方法返回服务的结果
     *
     * @return
     */
    TData getData();

    /**
     * 消息
     *
     * @return
     */
    String getMessage();

    /**
     * 状态码,{@link #SUCCESS_STATUS}表示成功,{@link #FAILURE_STATUS}表示失败，如有其他状态请参见具体服务文档
     *
     * @return
     */
    int getStatus();

    @JSONField(serialize = false)
    default boolean isSuccess() {
        return this.getStatus() == SUCCESS_STATUS;
    }

    void setData(TData data);

    void setMessage(String message);

    void setStatus(int status);
}
